package org.ihelpuoo.orm.handler.map;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

import org.ihelpuoo.orm.IIIException;
import org.ihelpuoo.orm.ObjectRule;
import org.ihelpuoo.orm.handler.ObjectProcessor;
import org.ihelpuoo.orm.handler.SaveObjectFieldHandler;

public class MapSaveObjectFieldHandler extends SaveObjectFieldHandler
{

	public MapSaveObjectFieldHandler(ObjectProcessor beanHandler)
	{
		super(beanHandler);
	}

	@SuppressWarnings("unchecked")
	@Override
	protected Object prepareSubSource(ObjectRule r, Field f, Object src) throws Exception
	{
		String key = r.getAlias(f);
		Map map = new HashMap();
		((Map)src).put(key,map);
		return map;
	}

	@Override
	protected void setObjectToSourceObject(ObjectRule br, Object src, Object obj)
			throws IIIException
	{
		processor.update(br,src,obj,null,null);
	}

}
